package com.eolcum.evo.thread;

import android.content.Context;
import android.content.Intent;
import com.google.gson.Gson;

public class Logger implements Runnable {

	private RoomTemperatureController rtc;
	private Context context;
	public Logger() {
	}

	@Override
	public void run() {
		Gson gson;
		while (true) {

			gson = new Gson();
			Intent intent = new Intent();
			intent.setAction("com.eolcum.evo.service.EvoLoggerService");
			intent.putExtra("function_name", "logRTC");
			intent.putExtra("RTCLog", gson.toJson(rtc));
			context.startService(intent);
			
			try {
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
	}

	/**
	 * @return the rtc
	 */
	public synchronized RoomTemperatureController getRtc() {
		return rtc;
	}

	/**
	 * @param  the rtc to set
	 */
	public synchronized void setRtc(RoomTemperatureController rtc) {
		this.rtc = rtc;
	}
}
